package flyweight;

public class TreeFactory {

    Tree d, c;

    public TreeFactory() {
        d = new DeciduousTree();
        c = new ConiferTree();
    }

    public Tree getTree(String type) throws Exception {
        if ("deciduous".equals(type)) {
            return d;
        } else if ("conifer".equals(type)) {
            return c;
        } else {
            throw new Exception("Invalid kind of tree");
        }
    }
}
